import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/lsEchartsDemo'
    },
    {
      path: '/lsEchartsDemo',
      name: 'lsEchartsDemo',
      meta: {
        title: 'lsEchartsDemo'
      },
      component: () => import('../views/lsEchartsDemo.vue')
    },
    {
      path: '/lsNodataDemo',
      name: 'lsNodataDemo',
      meta: {
        title: 'lsNodataDemo'
      },
      component: () => import('../views/lsNodataDemo.vue')
    },
    {
      path: '/lsTabsDemo',
      name: 'lsTabsDemo',
      meta: {
        title: 'lsTabsDemo'
      },
      component: () => import('../views/lsTabsDemo.vue')
    },
    {
      path: '/lsTableDemo',
      name: 'lsTableDemo',
      meta: {
        title: 'lsTableDemo'
      },
      component: () => import('../views/lsTableDemo.vue')
    }
  ]
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
